<?php
namespace app\redbag\controller;
use app\ApiRest;
use app\redbag\model\staffRecord;
use think\App;
use app\redbag\model\Record as Model;
use app\redbag\model\IndexActive;
use think\facade\Db;


class IndexRecord extends ApiRest
{

    protected $model;

    protected $company_model;

    protected $log_model;

    protected $active_model;

    protected $count_model;

    public function __construct(App $app) {
        parent::__construct($app);

        $this->model= new Model();

        $this->active_model  = new IndexActive();

    }


    /**
     * @author chenniang
     * @DataTime: 2020-04-10 14:42
     * @功能说明:用户领取详情
     *
     */
    public function userRecordList(){

        $input = $this->_input;

        if(isset($input['status'])&&$input['status']!=999){

            if($input['status']==-1){

                $dis[] = ['status','in',[-1,0]];

            }else{

                $dis[] = ['status','=',$input['status']];
            }

        }
        $dis[] = ['uniacid','=',$this->_uniacid];

        $dis[] = ['user_id','=',$this->getUserId()];

        $data = $this->model->recordList($dis);

        return $this->success($data);

    }


    /**
     * User: chenniang
     * Date: 2019-09-26 10:32
     * @return void
     * descption:生成活动二维码
     */
    public function getQr(){

        $input = $this->_input;

        $qr    = getCache($this->getUserId().'-'.$input['type'].'-'.$input['staff_id'].'-'.$input['id']."-redbag",$this->_uniacid);

        if(empty($qr)){

            $input['pid'] = $this->getUserId();

            $data = longbingCreateWxCode($this->_uniacid,$input,$input['page']);

            $data = transImagesOne($data ,['qr_path'] ,$this->_uniacid);

            $qr   = $data['qr_path'];

            setCache($this->getUserId().'-'.$input['type'].'-'.$input['staff_id'].'-'.$input['id']."-redbag",$qr,3600,$this->_uniacid);
        }
        return $this->success($qr);
    }







}
